package dao.impl;

import com.mysql.cj.Session;
import dao.IGoodsDao;
import model.Goods;
import org.apache.ibatis.session.SqlSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import java.util.List;
import java.util.Map;

@Repository
public class GoodsDao implements IGoodsDao {
    @Autowired
    private SqlSession sqlSession;

    @Override
    public List<Goods> query(Goods goods) {
        String url="dao.IGoodsDao.";
        return sqlSession.selectList(url+"query",goods);
    }

    @Override
    public int totalCount(Goods goods) {
        return  sqlSession.selectOne("dao.IGoodsDao.totalCount", goods);
    }

    @Override
    public List<Goods> selectParentId(Goods goods) {
        return  sqlSession.selectList("dao.IGoodsDao.selectParentId", goods);
    }

    @Override
    public List<Goods> selectSortId(Goods goods) {
        return  sqlSession.selectList("dao.IGoodsDao.selectSortId", goods);
    }

    @Override
    public int update(Goods goods) {
        return  sqlSession.update("dao.IGoodsDao.update", goods);
    }

    @Override
    public int insert(Goods goods) {
        return  sqlSession.insert("dao.IGoodsDao.insert", goods);
    }

    @Override
    public List<Goods> queryOff(Goods goods) {
        return  sqlSession.selectList("dao.IGoodsDao.queryOff", goods);
    }

    @Override
    public int totalCountOff(Goods goods) {
        return sqlSession.selectOne("dao.IGoodsDao.totalCountOff", goods);
    }

    @Override
    public int updateStatus(Map<String, String> map) {
        return  sqlSession.update("dao.IGoodsDao.updateStatus", map);
    }


}
